import dayjs from 'dayjs';
import { DIC_PROPS } from './enums';
export const commonProps = {
  modelValue: {
    type: Array,
    default: () => {
      return [];
    }
  },
  prop: {
    type: String,
    default: ''
  },
  label: {
    type: String,
    default: ''
  },
  type: {
    type: String,
    default: ''
  },
  placeholder: {
    type: String,
    default: ''
  },
  clearable: {
    type: Boolean,
    default: false
  },
  dic: {
    type: Array,
    default: () => []
  },
  disabled: {
    type: Boolean,
    default: false
  },
  readonly: {
    type: Boolean,
    default: false
  },
  props: {
    type: Object,
    default: () => DIC_PROPS
  },
  change: {
    type: Function,
    default: () => {}
  },
  focus: {
    type: Function,
    default: () => {}
  },
  blur: {
    type: Function,
    default: () => {}
  },
  clear: {
    type: Function,
    default: () => {}
  },
  click: {
    type: Function,
    default: () => {}
  },
  confirm: {
    type: Function,
    default: () => {}
  },
  format: {
    type: Function,
    default: (val) => {
      return dayjs(val).format('YYYY-MM-DD');
    }
  }
};

export function useCommonProps({ props }) {
  const idKey = computed(() => {
    return props.id || DIC_PROPS['id'];
  });
  const nameKey = computed(() => {
    return props.name || DIC_PROPS['name'];
  });
  const titleKey = computed(() => {
    return props.title || DIC_PROPS['title'];
  });
  const labelKey = computed(() => {
    return props.label || DIC_PROPS['label'];
  });
  const valueKey = computed(() => {
    return props.value || DIC_PROPS['value'];
  });
  const childrenKey = computed(() => {
    return props.value || DIC_PROPS['children'];
  });
  return { idKey, nameKey, titleKey, labelKey, valueKey, childrenKey };
}
